package sky.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sky.dao.FlightDAO;
import sky.domain.Flight;
import sky.exceptions.bookTicketException;
import sky.service.FlightService;
import sky.tro.TicketFinder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 24.04.13
 * Time: 17:09
 * To change this template use File | Settings | File Templates.
 */
@Service
public class FlightServiceImpl implements FlightService{

    @Autowired
    private FlightDAO flightDAO;

    @Override
    @Transactional
    public void addFlight(Flight flight) {
        flightDAO.addFlight(flight);
    }

    @Override
    @Transactional
    public List<Flight> listFlight() {
        return flightDAO.listFlight();
    }

    @Override
    @Transactional
    public List<Flight> sortingList(String sortParam) {
        return flightDAO.sortingList(sortParam);
    }

    @Override
    @Transactional
    public void removeFlight(Integer id) {
        flightDAO.removeFlight(id);
    }

    @Override
    @Transactional
    public List<Flight> FindByFinder(TicketFinder finder, String sortStr, String ticketType) {
        return flightDAO.findByFinder(finder, sortStr, ticketType);
    }

    @Override
    @Transactional
    public Flight getFlightById(Integer id) {
        return flightDAO.getFlightById(id);
    }

    @Override
    @Transactional
    public void editFlight(Flight flight) {
        flightDAO.editFlight(flight);
    }

    @Override
    @Transactional
    public void bookTickets(Integer id, Integer numberOfTickets, String ticketType) {
        flightDAO.bookTickets(id, numberOfTickets, ticketType);
    }
}
